#!/usr/bin/env node
var login = (num) => {
    var index = 0;
    var timer = setInterval(() => {
        console.log(index);
        index++;
        if (index >= num) clearInterval(timer);
    }, 10);
}

login(10);

function countTimePrint(player, labelIndexs) {
    var index = 0;
    return {
        countTimePrintStart : () => {
        labelIndexs.push(++index);
        console.log('start', index, player.uid)
        console.time('Num<' + index + '> getRecommendedPlayer uid<' + player.uid + '>');
    },
        countTimePrintEnd : () => {
        console.log('end', labelIndexs, player.uid)
        while (labelIndexs.length > 0) {
            try {
                var labelIndex = labelIndexs.shift();
                console.timeEnd('Num<' + labelIndex + '> getRecommendedPlayer uid<' + player.uid + '>');
                break;
            } catch (e) {
                console.error('Num<%d> getRecommendedPlayer uid<%d> error<%s:%s>', labelIndex, player.uid, e.name, e.message);
            }
        }
        }
    };
}
a = {uid: 'a'};
b = {uid: 'b'};


c = new countTimePrint(a, []);
d = new countTimePrint(b, []);
a.countTimePrintStart = c.countTimePrintStart;
a.countTimePrintEnd = c.countTimePrintEnd;
b.countTimePrintStart = d.countTimePrintStart;
b.countTimePrintEnd = d.countTimePrintEnd;
a.countTimePrintStart();
b.countTimePrintStart();
a.countTimePrintStart();
b.countTimePrintStart();
b.countTimePrintEnd();
a.countTimePrintEnd();
b.countTimePrintEnd();
a.countTimePrintEnd();
/*
var test = (uid) => {
    var index = 0;
    return () => {
        console.log(uid, index++);
    };
}

a = test('a');
b = test('b');

a();
a();
b();
a();

b();
b();
*/
